package com.example.demo.niuke;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @Author: liull
 * @Description: 密码匹配 ABBA 匹配个数为：4
 * @Date: Created in 13:10 2020/4/1
 * @Modified By:
 */
public class Main46 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        //        System.out.println(Arrays.toString("127.0.0.1".split("\\.")));
        while ((line = br.readLine()) != null) {
            System.out.println(calcCapital(line));
        }

    }

    private static int calcCapital(String s) {
        String l;
        //        return (l = longestCommSubStr(s, new StringBuilder(s).reverse().toString())) == null ? 0 : l.length();
        return longestCommSubStr(s, new StringBuilder(s).reverse().toString()).length();

    }

    private static String longestCommSubStr(String str1, String str2) {
        //        for (int i = str1.length(); i > 0; i--) { //长度从大到小子串
        //            for (int j = 0; j < str1.length() - i + 1; j++) {
        //                if (str2.contains(str1.substring(j, j + i))) {
        //                    return str1.substring(j, j + i);
        //                }
        //            }
        //        }
        String current = "";
        for (int i = 0; i < str1.length(); i++) {
            for (int begin = 0, end = str1.length() - i; end <= str1.length(); begin++, end++) {
                current = str1.substring(begin, end);
                if (str2.contains(current)) {
                    return current;
                }
            }
        }
        return null;
    }

}